home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak Vol C-14
/
Vol C-14.iso
/
games
/
smashing.swf
/
scripts
/
frame_58
/
DoAction.as
Wrap
Text File
|
2012-04-23
|
4KB
|
156 lines
function padActions()
{
if(Key.isDown(37) or Key.isDown(39))
{
Mouse.hide();
if(Key.isDown(39) && !Key.isDown(37))
{
usingKeyboard = true;
pad.TargetX += padKeyJump;
padSpeed++;
}
if(!Key.isDown(39) && Key.isDown(37))
{
usingKeyboard = true;
pad.TargetX -= padKeyJump;
padSpeed--;
}
if(!Key.isDown(39) && !Key.isDown(37))
{
padSpeed = 0;
}
tempXMouse = int(_xmouse);
}
else if(tempXMouse != int(_xmouse))
{
Mouse.show();
if(leftWall >= int(_xmouse))
{
pad.TargetX = leftWall;
}
else if(int(_xmouse) >= rightWall)
{
pad.TargetX = rightWall;
}
else
{
pad.TargetX = int(_xmouse);
}
padSpeed = int(pad.TargetX - pad._x);
}
if(spawnNewBall)
{
spawnNewBall = false;
if(ballsActive < 1 && readyToShootBall == true)
{
pad.left.ballStuck._visible = false;
pad.right.ballStuck._visible = false;
generateBall(true,pad._x,pad._y - pad._height);
}
}
if(leftWall >= pad.TargetX)
{
pad.TargetX = leftWall;
}
else if(pad.TargetX >= rightWall)
{
pad.TargetX = rightWall;
}
if(pad.left.gotoState == "firepower")
{
if((Key.isDown(32) or mouseButtonDown) && bulletsFired < 3)
{
if(weaponFired)
{
sndChargeUp.start(0,0);
}
spaceKeyRelesed = false;
mouseButtonDown = true;
usingKeyboard = true;
weaponFired = false;
fireAmount++;
if(pad.left.weapon._totalframes >= fireAmount)
{
pad.left.weapon.gotoAndStop(fireAmount);
pad.right.weapon.gotoAndStop(fireAmount);
}
weaponActivated = true;
}
else if((!spaceKeyRelesed or !mouseButtonDown) && weaponActivated && !weaponFired)
{
spaceKeyRelesed = true;
weaponFired = true;
if(1 < pad.left.weapon._currentframe && bulletsFired < 1)
{
sndChargeUp.stop();
bulletsFired++;
clipCounter++;
attachMovie("mcBullet","mcBullet" + clipCounter,clipCounter);
this["mcBullet" + _root.clipCounter]._x = pad._x;
this["mcBullet" + _root.clipCounter]._y = pad._y - pad._height;
bulletSize = this["mcBullet" + _root.clipCounter]._xscale + pad.left.weapon._currentframe * 4;
this["mcBullet" + _root.clipCounter]._xscale = bulletSize;
this["mcBullet" + _root.clipCounter]._yscale = bulletSize;
}
fireAmount = 1;
pad.left.weapon.gotoAndStop(fireAmount);
pad.right.weapon.gotoAndStop(fireAmount);
}
}
if(padSpeed != 0)
{
if(usingKeyboard)
{
pad._x += (pad.TargetX - pad._x) / 1.5;
}
else
{
pad._x = pad.TargetX;
}
}
}
function ballHitPad(ball)
{
if(pad.left.edge.hitTest(ball.testMoveX,ball.testMoveY,true))
{
sndBallHitPadEdge.start(0,0);
_root.pad.left.edgeGlass.gotoAndPlay(1);
ball.SpeedX = maxSpeed;
}
else if(pad.right.edge.hitTest(ball.testMoveX,ball.testMoveY,true))
{
sndBallHitPadEdge.start(0,0);
_root.pad.right.edgeGlass.gotoAndPlay(1);
ball.SpeedX = - maxSpeed;
}
else
{
sndBallHitPad.start(0,0);
padMove = ball.SpeedX + padSpeed;
if(- maxSpeed >= padMove)
{
ball.SpeedX = - maxSpeed;
}
else if(padMove >= maxSpeed)
{
ball.SpeedX = maxSpeed;
}
else
{
ball.SpeedX = padMove;
}
}
if(0 >= ball.SpeedX && 0 >= ball.SpeedY)
{
ballBounce(ball,pad,"top","right");
}
else if(ball.SpeedX >= 0 && 0 >= ball.SpeedY)
{
ballBounce(ball,pad,"top","left");
}
}
pad.TargetX = 350;
padKeyJump = 26;
weaponFired = true;
gotoAndPlay(66);